package design_pattern.iterator;

import java.util.ArrayList;

public class Client {
    public static void main(String[] args) {
        ArrayList<Object> products = new ArrayList<>();
        products.add("hand_write");
        products.add("b");
        products.add("c");
        products.add("d");
        products.add("e");

        AbstractObjectList list;
        AbstractIterators iterators;

        list = new ProductList(products);
        iterators = list.createIterators();

        System.out.println("正向遍历");
        while (!iterators.isLast()) {
            System.out.print(iterators.getNextItem() + ",");
            iterators.next();
        }
        System.out.println();
        System.out.println("----------------------------------");
        System.out.println("逆向遍历");
        while (!iterators.isFirst()) {
            System.out.print(iterators.getPreviousItem() + ",");
            iterators.previous();
        }
    }
}
